﻿<%@ Page Language="C#" MasterPageFile="~/manager/page/ManagerMasterPage.Master" AutoEventWireup="true" CodeBehind="user.aspx.cs" Inherits="Com.Web.coffinegurunaru.manager.user.user" %>
<%@ Register TagPrefix="UC" TagName="Menu" Src="~/manager/user/menu.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="phHead" runat="server">
<link rel="StyleSheet" href="/css/jquery-ui.css" type="text/css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="phContent" runat="server">
<hr />
<br />
<table>
<tr>
	<td valign="top">
<UC:Menu SubPageType=1 runat="server" />
	</td>
	<td style="width:20px;"></td>
	<td>
<table cellpadding="0" cellspacing="1" style="background-color:Gray; width:100%;" id="m_UserSearch">
<tr>
	<td style="background-color:Silver; text-align:center; height:25px;">내/외국인</td>
	<td style="background-color:#ffffff;">&nbsp;&nbsp;
		<select style="width:200px" class="m_LocalUserType">
			<option value="">선택안함</option>
			<option value="Y">내국인</option>
			<option value="N">외국인</option>
		</select>
	</td>
</tr>
<tr>
	<td style="background-color:Silver; text-align:center; height:25px;">그룹검색</td>
	<td style="background-color:#ffffff;">&nbsp;&nbsp;
		<select style="width:200px" class="m_GroupType">
			<option value="0">선택안함</option>
			<option value="1">운영자 [ 존재하지 않음]</option>
			<option value="2">회원</option>
			<option value="3">가맹점</option>
		</select>
	</td>
</tr>
<tr>
	<td style="background-color:Silver; text-align:center; height:25px;">날짜검색</td>
	<td style="background-color:#ffffff;">&nbsp;&nbsp;
		<input type="text" class="m_DateJoin_Start" readonly="readonly" style="width:90px;" /> ~ <input type="text" class="m_DateJoin_End" readonly="readonly" style="width:90px;" />
		&nbsp;&nbsp;&nbsp;<input type="button" class="m_DateJoin_Remove" value="날짜삭제" />
	</td>
</tr>
<tr>
	<td style="background-color:Silver; text-align:center; height:25px;">검색</td>
	<td style="background-color:#ffffff;">&nbsp;&nbsp;
		<select style="width:100px" class="m_SearchType">
			<option value="0">선택안함</option>
			<option value="1">아이디</option>
			<option value="2">이름</option>
		</select>&nbsp;&nbsp;
	<input type="text" class="m_SearchValue" style="width:200px;"/></td>
</tr>
<tr>
	<td colspan="2" style="background-color:#ffffff; text-align:center;"><input type="button" id="m_btnSearch" class="m_btnSearch" value="검색" /></td>
</tr>
</table>
<br />

<table width="100%">
<tr>
	<td style="text-align:right;">한페이지 개수 : 
		<select id="selPageSize">
			<option value="10">10</option>
			<option value="20">20</option>
			<option value="30">30</option>
			<option value="50">50</option>
			<option value="100">100</option>
		</select>
	</td>
</tr>
<tr>
	<td align="center">
		<div id="m_UserList" ></div>
		<br />
		<div id="m_Pager"></div>
		<div id="m_UserView"></div>
	</td>
</tr>
</table>

	</td>
</tr>
</table>
<script language="javascript" type="text/javascript">
(function($){
	$.Member = {};
	
	$.Member = {
		Init : function() {
			$("#m_Pager").pager({
				pageSize : 10,
				useCallback : true,
				pageNo : 1,
				callback:function(pageNo) {
					$.Member.GetList();
				}
			});
			$("#m_UserSearch input.m_DateJoin_Start").datepicker({
				showButtonPanel: true
			});
			$("#m_UserSearch input.m_DateJoin_Start").datepicker( "option", "dateFormat", "yy-mm-dd" );

			$("#m_UserSearch input.m_DateJoin_End").datepicker({
				showButtonPanel: true
			});
			$("#m_UserSearch input.m_DateJoin_End").datepicker( "option", "dateFormat", "yy-mm-dd" );
			
			$("#m_UserSearch input.m_DateJoin_Remove").click(function() {
				$("#m_UserSearch input.m_DateJoin_Start").val( "" );
				$("#m_UserSearch input.m_DateJoin_End").val( "" );
			});
			
			$("#m_UserSearch select.m_LocalUserType").change(function() {
				$("#m_UserSearch input.m_DateJoin_Remove").click();
				$("#m_UserSearch select.m_SearchType").val( 0 );
				$("#m_UserSearch input.m_SearchValue").val( "" );
				$("#m_Pager").pager("option", "currentPageNo", 1);
				$.Member.GetList();
			});
			
			$("#m_UserSearch select.m_GroupType").change(function() {
				$("#m_UserSearch input.m_DateJoin_Remove").click();
				$("#m_UserSearch select.m_SearchType").val( 0 );
				$("#m_UserSearch input.m_SearchValue").val( "" );
				$("#m_Pager").pager("option", "currentPageNo", 1);
				$.Member.GetList();
			});
			
			$("#m_UserSearch input.m_btnSearch").click(function() {
				if ( $("#m_UserSearch input.m_SearchValue").val() != 0 )
				{
					if ( $.trim($("#m_UserSearch input.m_SearchValue").val()) == "" )
					{
						alert( "검색할 내용을 입력하세요" );
						return;
					}
				}
				$("#m_Pager").pager("option", "currentPageNo", 1);
				$.Member.GetList();
			});
			
			$("#selPageSize").change(function() {
				$("#m_Pager").pager("option", "pageSize", $(this).val())
				$("#m_Pager").pager("option", "currentPageNo", 1);
				$.Member.GetList();
			});
			
			$.Member.GetList();
		},
		
		GetList : function() {
			var IsLocalUser = $("#m_UserSearch select.m_LocalUserType").val();
			var nGroupType = $("#m_UserSearch select.m_GroupType").val();
			var strDateJoin_start = $("#m_UserSearch input.m_DateJoin_Start").val();
			var strDateJoin_end = $("#m_UserSearch input.m_DateJoin_End").val();
			var SearchType = $("#m_UserSearch select.m_SearchType").val();
			var SearchValue = $("#m_UserSearch input.m_SearchValue").val();

			$("#m_UserList").ajaxNet(
			"/manager/user/userMethod.aspx?_vb=GetList",
			{
				"PageNo" : $("#m_Pager").pager("option", "currentPageNo"),
				"PageSize" : $("#m_Pager").pager("option", "pageSize"),
				"IsLocalUser" : IsLocalUser,
				"nGroupType" : nGroupType,
				"strDateJoin_start" : strDateJoin_start,
				"strDateJoin_end" : strDateJoin_end,
				"SearchType" : SearchType,
				"SearchValue" : SearchValue
			}, function(results, context)
			{
				$("#m_UserList").html( results[ 0 ] );
				$("#m_Pager").pager("update", results[1]);
				
				$("#m_UserList input.m_RemoveUser").click(function() {
					$.Member.Remove( $(this).closest("tr") );
				});
				
				$("#m_UserList tr td.select").mouseover(function() {
					var data = $(this).closest("tr").tagdata();
					if ( data.UserNo != undefined ) {
						$(this).closest("tr").css({"background-color":"#eeeeee", "cursor":"pointer"});
					}
				}).mouseout(function() {
					var data = $(this).closest("tr").tagdata();
					if ( data.UserNo != undefined ) {
						$(this).closest("tr").css({"background-color":"#ffffff", "cursor":"default"});
					}
				}).click(function() {
					var data = $(this).closest("tr").tagdata();
					if ( data.UserNo != undefined ) {
						$("#m_UserView").ajaxNet(
						"/manager/user/userMethod.aspx?_vb=GetInfo",
						{
							"UserNo" : data.UserNo
						}, function(results, context)
						{
							$("#m_UserView").html(results);
							$("#m_UserView").tagdata().UserNo = data.UserNo;
							$.Join.Init();
							$("#m_UserView").show();
							$("#m_UserList").hide();
							$("#m_Pager").hide();
						});
					}
				});
			});
		},
		
		Remove : function( $tr )
		{
			var data = $tr.tagdata();
			if ( confirm( "정말로 탈퇴 처리하시겠습니까?" ) )
			{
				$("#m_UserList").ajaxNet(
				"/manager/user/userMethod.aspx?_vb=Remove",
				{
					"UserNo" : data.UserNo
				}, function(results, context)
				{
					$.Member.GetList();
				});
			}
		}
	};
	
	$(function() {
		$.Member.Init();
	});
})(jQuery);



(function($) {
	$.Join = {};
	
	$.Join = {
		Init : function() {
			$("#btnUserSave").click(function() {
				$.Join.Submit();
				
				return false;
			});
			$("#btnUserCancle").click(function() {
				$("#m_UserView").hide();
				$("#m_UserList").show();
				$("#m_Pager").show();
				return false;
			});
			
			$("#strEmail3").change(function() {
				$("#strEmail2").val( $(this).val() );
				if ( $(this).val() != "" )
					$("#strEmail2").attr("readonly", "readonly")
				else
					$("#strEmail2").attr("readonly", null)
			});
			
			$("#strPostNo1, #strPostNo1, #strAddress1, #btnPostSearch").click(function() {
				$.Coffine.postopen("$.Join.Post");
				return false;
			});
		},
		
		IDCheck : function(userid) {
			$("#strUserID, #strUserID2").val( userid );
		},
		
		Post : function(post1, post2, address) {
			$("#strPostNo1").val(post1);
			$("#strPostNo2").val(post2);
			$("#strAddress1").val(address);
			$("#strAddress2").focus();
		},
		
		GetRadioValue : function( $rdos ) {
			var retValue = "";
			$rdos.each(function() {
				if ( $(this).attr("checked" ) == "checked" )
				{
					retValue =  $(this).val();
				}
			});
			return retValue;
		},
		
		Submit : function() {
			if ( $("#strUserPWD1").val() != "" )
			{
				if ( $("#strUserPWD1").val().length < 8) {
					alert( "비밀번호는 8글자 이상입니다.");
					return false;;
				}
				
				if (!$.Coffine.isEngNumber( $("#strUserPWD1").val() ) ) {
					alert( "비밀번호는 영문과 숫자로만 입력해주세요");
					return false;;
				}
				
				if ($("#strUserPWD1").val() != $("#strUserPWD2").val() ) {
					alert( "비밀번호가 틀립니다.");
					return false;;
				}
			}
			if ($("#strUserName").val() == ""  ) {
				alert( "성명을 입력해주세요.");
				return false;;
			}
			
			if ( !$.Coffine.isEngNumber($("#strEmail1").val()) )
			{
				alert( "이메일은 영문으로만 입력이 가능합니다.");
				return false;;
			}
			
			var UserNo = $("#m_UserView").tagdata().UserNo;
			var IsLocalUser = $("#IsLocalUser1").val();
			var UserID = $("#strUserID").val();
			var UserPWD = $("#strUserPWD1").val();
			var UserName = $("#strUserName").val();
			var Email1 = $("#strEmail1").val();
			var Email2 = $("#strEmail2").val();
			var IsEmail = $.Join.GetRadioValue( $("input:[name=IsEmail]") );
			var Question = $("#n1Question").val();
			var Answer = $("#strAnswer").val();
			var PostNo1 = $("#strPostNo1").val();
			var PostNo2 = $("#strPostNo2").val();
			var Address1 = $("#strAddress1").val();
			var Address2 = $("#strAddress2").val();
			var HomePhone1 = $("#strHomePhone1").val();
			var HomePhone2 = $("#strHomePhone2").val();
			var HomePhone3 = $("#strHomePhone3").val();
			var MobilePhone1 = $("#strMobilePhone1").val();
			var MobilePhone2 = $("#strMobilePhone2").val();
			var MobilePhone3 = $("#strMobilePhone3").val();
			var IsSMS = $.Join.GetRadioValue( $("input:[name=IsSMS]") );
			var Birthday_Year = $("#strBirthday1").val();
			var Birthday_Month = $("#strBirthday2").val();
			var Birthday_Day = $("#strBirthday3").val();
			var IsLunar = $("#IsLunar").val();
			var JoinMotiveType = $("#n1JoinMotiveType").val();
			
			if ( $(":radio[name='codeSex']:checked").length < 1 ) {
				alert( "성별을 선택하세요");
				return false;
			}
			var CodeSex = $(":radio[name='codeSex']:checked").val();

			$("#m_UserView").ajaxNet(
			"/manager/user/userMethod.aspx?_vb=Modify",
			{
				"UserNo" : UserNo
			,	"IsLocalUser" : IsLocalUser
			,	"UserID" : UserID
			,	"UserPWD" : UserPWD
			,	"UserName" : UserName
			,	"Email1" : Email1
			,	"Email2" : Email2
			,	"IsEmail" : IsEmail
			,	"Question" : Question
			,	"Answer" : Answer
			,	"PostNo1" : PostNo1
			,	"PostNo2" : PostNo2
			,	"Address1" : Address1
			,	"Address2" : Address2
			,	"HomePhone1" : HomePhone1
			,	"HomePhone2" : HomePhone2
			,	"HomePhone3" : HomePhone3
			,	"MobilePhone1" : MobilePhone1
			,	"MobilePhone2" : MobilePhone2
			,	"MobilePhone3" : MobilePhone3
			,	"IsSMS" : IsSMS
			,	"Birthday_Year" : Birthday_Year
			,	"Birthday_Month" : Birthday_Month
			,	"Birthday_Day" : Birthday_Day
			,	"IsLunar" : IsLunar
			,	"JoinMotiveType" : JoinMotiveType
			,	"CodeSex" : CodeSex
			}, function(results, context)
			{
				$.Member.GetList();
				$("#btnUserCancle").click();
			});

			return false;
		}
	}
	
	$(function() {
		$.Join.Init();
	});
})(jQuery);
</script>


</asp:Content>
